<template>
    <view class="search">
        <view class="box">
            <image class="icon" src="/static/images/icon/search.png"></image>
            <text class="txt">搜索, 共{{goodsCount}}款好物</text>
        </view>
    </view>
</template>

<script>
    export default {
        name: "mySearch",
        data() {
            return {
                goodsCount: '' //搜索组件显示的商品数据量
            };
        },

        methods: {
            async getGoodsCount() {
                const res = await uni.$http.get('/goods/count')
                // console.log(res);
                this.goodsCount = res.goodsCount
            }
        },
        created() {
           this.getGoodsCount()
        }
    }
</script>

<style lang="scss" scoped>
    .search {
        width: 100%;
        background-color: #fff;
        padding: 6px 24rpx;
        box-sizing: border-box;
    }

    .search .box {
        background-color: red;
        display: flex;
        justify-content: flex-start;
        align-items: center;
        background-color: #fafafa;
        box-sizing: border-box;
        height: 30px;
        border-radius: 30rpx;
        padding-left: 20rpx;
    }

    .search .icon {
        width: 30rpx;
        height: 30rpx;
    }

    .search .txt {
        height: 42rpx;
        line-height: 42rpx;
        color: #666;
        padding-left: 10rpx;
        font-size: 28rpx;
    }
</style>
